package test
{
	import Elegant.ELGManager;
	import Elegant.utils.KeyboardListener;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	import lynch.core.Core;
	import lynch.enum.MapInfoEnum;
	import lynch.map.WorldMap;
	import lynch.net.loading.LynchLoader;
	import lynch.net.loading.ResourceLoader;
	
	/**
	 * ...
	 * @author 小痛
	 */
	public class MapTest
	{
		private var map:WorldMap;
		
		public function MapTest()
		{
			ResourceLoader.loadImgs(Vector.<String>(["resource/image/miniMap/1.jpg"]), onComplete);
		}
		
		private function onComplete(e:Array):void
		{
			var info:MapInfoEnum = new MapInfoEnum();
			info.mapID = 1;
			info.mapVTiles = 20;
			info.mapHTiles = 10;
			info.mapName = "测试地图";
			info.waypoints = Vector.<int>([0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1]);
			info.miniMapTexture = e[0].bitmapData;
			
			map = Core.map;
			map.initializeInfo(info);
			map.flashTo(256, 0);
			map.dragEnabled = true;
			Core.miniMap.x = 200;
			Core.miniMap.y = 200;
			
			KeyboardListener.addKeyBoardListener(Keyboard.LEFT + "", onLeft);
			KeyboardListener.addKeyBoardListener(Keyboard.RIGHT + "", onRight);
			KeyboardListener.addKeyBoardListener(Keyboard.UP + "", onUp);
			KeyboardListener.addKeyBoardListener(Keyboard.DOWN + "", onDown);
			//Starling.current.stage.addChild(Core.miniMap);
		}
		
		private function onLeft(e:Event):void
		{
			map.moveTo(map.x - 128, map.y, .5);
		}
		
		private function onRight(e:Event):void
		{
			map.moveTo(map.x + 128, map.y, .5);
		}
		
		private function onUp(e:Event):void
		{
			map.moveTo(map.x, map.y - 128, .5);
		}
		
		private function onDown(e:Event):void
		{
			map.moveTo(map.x, map.y + 128, .5);
		}
	}

}